home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_63593.txt < prev    next >
Text File  |  1991-02-27  |  2KB  |  110 lines

  1. -- card: 63593 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (field)
  9. -- low flags: 00
  10. -- high flags: 0007
  11. -- rect: left=30 top=78 right=296 bottom=478
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 0
  15. -- font id: 4
  16. -- text size: 9
  17. -- style flags: 0
  18. -- line height: 12
  19. -- part name: 
  20.  
  21.  
  22. -- part contents for card part 1
  23. ----- text -----
  24. /*
  25. *   FILE:     graftest.c
  26. *   AUTHOR:   R. Gonzalez
  27. *   CREATED:  Aug. 5, 1990
  28. *
  29. *   Demonstrate use of Mac_Screen class.
  30. *
  31. *   PROJECT CONTENTS:
  32. *   screen.c, graftest.c, ANSI, oops, MacTraps
  33. */
  34.  
  35. # include   "screen.h"
  36. # include   <math.h>
  37. # include   <oops.h>
  38.  
  39. # define    PI          3.1415926
  40.  
  41. double      get_input(void);
  42.  
  43. main()
  44. {
  45.     Mac_Screen  *mac_screen;
  46.     double      angle,
  47.                 x,
  48.                 y,
  49.                 old_x,
  50.                 old_y,
  51.                 width;
  52.     boolean     done;
  53.  
  54.     mac_screen = new(Mac_Screen);
  55.     mac_screen->init();
  56.  
  57.     while ((width = get_input()) != 0.)
  58.     {
  59.         mac_screen->set_view(width,
  60.                 width/mac_screen->get_aspect_ratio(),
  61.                 width/2.,
  62.                 width/2./mac_screen->get_aspect_ratio());
  63.  
  64.         for (angle = 0.,done = FALSE ; angle < 6*PI && !done;
  65.             angle+=PI/50.)
  66.         {
  67.             if (angle != 0.)
  68.             {
  69.                 mac_screen->color(BLACK);
  70.                 mac_screen->draw_line(0.,0.,old_x,old_y);
  71.                 mac_screen->draw_circle(old_x,old_y,.2);
  72.             }
  73.  
  74.             x = cos(angle);
  75.             y = sin(angle);
  76.  
  77.             mac_screen->color(WHITE);
  78.             mac_screen->draw_line(0.,0.,x,y);
  79.             mac_screen->draw_circle(x,y,.2);
  80.  
  81.             old_x = x;
  82.             old_y = y;
  83.  
  84.             if (mac_screen->mouse_button_is_down())
  85.                 done = TRUE;
  86.         }
  87.     }
  88.  
  89.     delete(mac_screen);
  90. }
  91.  
  92. double   get_input(void)
  93. {
  94.     double   width;
  95.  
  96.     printf("Width of view window (between 1 and 10, 0 to quit)?\n");
  97.     scanf("%lg",&width);
  98.     return width;
  99. }
  100.  
  101.  
  102.  
  103.  
  104. -- part contents for background part 4
  105. ----- text -----
  106. File 3 of 3.  Example application of foregoing Mac_Screen class:
  107.  
  108. -- part contents for background part 7
  109. ----- text -----
  110. 207